<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
	<head>
		<meta charset="utf-8">
		<title>这不是主页哦</title>
	</head>
	<link rel="stylesheet" type="text/css" th:href="@{/admin/bootstrap4/css/bootstrap.min.css}">
	<link rel="stylesheet" type="text/css" th:href="@{/admin/css/basictable.css}">
	<script th:src="@{/admin/bootstrap4/js/jquery-3.3.1.min.js}"></script>
	<script th:src="@{/admin/bootstrap4/js/bootstrap.js}"></script>

	<body>
	<div style="width:80%;height: 600px;margin-left:10% ;">
		<h2>查找结果</h2>
		<a type="button" class="btn btn-outline-info" th:href="@{/admin/userList}">返回</a>
		<table class="table">
			<thead class="bg-dark" style="color: white">
			<tr>
				<th scope="col">用户ID</th>
				<th scope="col">账户</th>
				<th scope="col">昵称</th>
				<th scope="col">性别</th>
				<th scope="col">邮箱</th>
				<th scope="col">头像</th>
				<th scope="col">角色</th>
				<th scope="col">状态</th>
				<th scope="col">操作</th>
			</tr>
			</thead>
			<tbody>
			<tr th:each="user:${userList}">
				<th scope="row">[[${user.userId}]]</th>
				<td>[[${user.userName}]]</td>
				<td>[[${user.userNickname}]]</td>
				<td>[[${user.userGender}]]</td>
				<td>[[${user.userEmail}]]</td>
				<td><img th:src="${user.userHeadphoto}" alt="null" style="width: 40px;height: 40px;" class="rounded-circle"></td>
				<td th:if="${user.userRole == 1}">普通用户</td>
				<td th:if="${user.userRole == 0}">会员用户</td>
				<td th:if="${user.userIsdelete == 0}"><span class="badge badge-success">正常</span></td>
				<td th:if="${user.userIsdelete == 1}"><span class="badge badge-danger">禁用</span></td>
				<td>
					<a type="button" class="btn btn-success" th:if="${user.userIsdelete == 1}" th:href="@{/admin/cancelBanUser2(id=${user.userId},key=${key})}">解禁</a>
					<a type="button" class="btn btn-danger" th:if="${user.userIsdelete == 0}" th:href="@{/admin/banUser2(id=${user.userId},key=${key})}">禁用</a>
<!--					点击跳出model模态框-->
					<a type="button" class="btn btn-info" data-toggle="modal" data-target="#ModalId" th:onclick="test([[${user.userId}]],[[${user.userName}]],[[${user.userPwd}]],[[${user.userNickname}]],[[${user.userEmail}]],[[${user.userPhone}]],[[${currentIndex}]],[[${key}]])">修改</a>
				</td>
			</tr>
			</tbody>
		</table>
	</div>
	<!-- 文件信息展示-弹窗 -->
	<div class="modal fade" id="ModalId" tabindex="-1" role="dialog"
		 aria-hidden="true">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<h4 class="modal-title" id="myModalLabel">修改用户信息</h4>
					<button type="button" class="close" data-dismiss="modal"
							aria-hidden="true">×</button>
				</div>
				<div class="modal-body">
					<!-- 内容主体begin -->
					<form id="myform" th:action="@{/admin/modUser2}" method="post">
						<input type="hidden" name="key">
						<input type="hidden" name="userid">
						<input type="hidden" name="currentindex">
						<div class="input-group input-group-sm mb-3">
							<div class="input-group-prepend">
								<span class="input-group-text" id="inputGroup-sizing-sm">用户账户</span>
							</div>
							<input type="text" class="form-control" aria-label="Sizing example input" aria-describedby="inputGroup-sizing-sm" name="username">
						</div>
						<div class="input-group input-group-sm mb-3">
							<div class="input-group-prepend">
								<span class="input-group-text">用户密码</span>
							</div>
							<input type="text" class="form-control" aria-label="Sizing example input" aria-describedby="inputGroup-sizing-sm" name="userpassword">
						</div>
						<div class="input-group input-group-sm mb-3">
							<div class="input-group-prepend">
								<span class="input-group-text">用户昵称</span>
							</div>
							<input type="text" class="form-control" aria-label="Sizing example input" aria-describedby="inputGroup-sizing-sm" name="usernickname">
						</div>
						<div class="input-group input-group-sm mb-3">
							<div class="input-group-prepend">
								<span class="input-group-text">用户邮箱</span>
							</div>
							<input type="text" class="form-control" aria-label="Sizing example input" aria-describedby="inputGroup-sizing-sm" name="useremail">
						</div>
						<div class="input-group input-group-sm mb-3">
							<div class="input-group-prepend">
								<span class="input-group-text">用户电话</span>
							</div>
							<input type="text" class="form-control" aria-label="Sizing example input" aria-describedby="inputGroup-sizing-sm" name="userphone">
						</div>
					</form>
					<!-- 内容主体end -->
				</div>
				<div class="modal-footer">
					<button form="myform" type="submit" class="btn btn-primary" id="ModalYesId">提交</button>
					<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
				</div>

			</div>
		</div>
	</div>
	</body>
	<script>


		function test(userid,username,userpassword,usernickname,useremail,userphone,currentindex,key){
			console.log("userid="+userid,"username="+username,"userpassword="+userpassword,"usernickname="+usernickname,"useremail="+useremail,"userphone="+userphone,"currentindex="+currentindex,"key="+key)
			$("[name='userid']").attr("value",userid)
			$("[name='username']").attr("value",username)
			$("[name='userpassword']").attr("value",userpassword)
			$("[name='usernickname']").attr("value",usernickname)
			$("[name='useremail']").attr("value",useremail)
			$("[name='userphone']").attr("value",userphone)
			$("[name='currentindex']").attr("value",currentindex)
			$("[name='key']").attr("value",key)
		}
	</script>
</html>
